﻿// ----------------------------------------------------------------
// Description : 实体类,该文件由MyGeneration生成
// Author      : 
// Create date : 2009-12-05
// ----------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.ComponentModel;

namespace ITOMMS.Entity
{
	/// <summary>
	///	tbMobileMessage Entity
	///	tbMobileMessage Entity短信息表
	/// </summary>
	[Serializable]
	public class tbMobileMessageEntity : BaseEntity<tbMobileMessageEntity,int>
	{
		
		#region 私有成员			
		
		private int _id; 
		private string _ReceiveMobile; 
		private string _SendMobile; 
		private string _MessageContent; 
		private bool? _SendState; 
		private DateTime? _SendDate; 
		private int _SEQNO;
		#endregion


		
		#region 默认( 空 ) 构造函数
		/// <summary>
		/// 默认构造函数
		/// </summary>
		public tbMobileMessageEntity()
		{
			_id = 0; 
			_ReceiveMobile = String.Empty; 
			_SendMobile = String.Empty; 
			_MessageContent = String.Empty; 
			_SendState =  null; 
			_SendDate =  null; 
			_SEQNO = 0;
		}
		#endregion
		
		#region 属性值校验
		
		/// <summary>
		/// 属性值校验
		/// </summary>
		public bool CheckValues()
		{
			bool bResult = true;
			string strError = "";
		
			if ( _id ==  0)
			{
				bResult = false;
				strError += "\r\n 非空值不能为: "+_id;
			}
			
			if( !bResult )
					throw new ArgumentOutOfRangeException(strError);
			return bResult;
			
		}
		
		#endregion
		
		
		
	
		#region Required Fields Only Constructor
		
		/// <summary>
		/// required (not null) fields only constructor
		/// </summary>
		public tbMobileMessageEntity(
		int para_id		)
		: this()
		{
					_id = para_id;
			_ReceiveMobile = String.Empty;
			_SendMobile = String.Empty;
			_MessageContent = String.Empty;
			_SendState = null;
			_SendDate = null;
		}
		#endregion 

		
		#region 公有属性
			
			/// <summary>
			/// 行号，顺序号。系统默认的属性
			/// </summary>
            [EditorBrowsable(EditorBrowsableState.Advanced)]
			public virtual int SEQNO
			{
				get { return _SEQNO; }
				set { _SEQNO = value; }
			}
		
			
		/// <summary>
		/// idid
		/// </summary>		
		public virtual int id
		{
			get { return _id; }
			set { _id = value; }
		}
			
		/// <summary>
		/// ReceiveMobile目标手机号
		/// </summary>		
		public virtual string ReceiveMobile
		{
			get { return _ReceiveMobile; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 20)
						throw new ArgumentOutOfRangeException("Invalid value for ReceiveMobile", value, value.ToString());
				
				_ReceiveMobile = value;
			}
		}
			
		/// <summary>
		/// SendMobile发送方手机号
		/// </summary>		
		public virtual string SendMobile
		{
			get { return _SendMobile; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 20)
						throw new ArgumentOutOfRangeException("Invalid value for SendMobile", value, value.ToString());
				
				_SendMobile = value;
			}
		}
			
		/// <summary>
		/// MessageContent信息内容
		/// </summary>		
		public virtual string MessageContent
		{
			get { return _MessageContent; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 70)
						throw new ArgumentOutOfRangeException("Invalid value for MessageContent", value, value.ToString());
				
				_MessageContent = value;
			}
		}
			
		/// <summary>
		/// SendState发送状态  0失败，1为成功
		/// </summary>		
		public virtual bool? SendState
		{
			get { return _SendState; }
			set { _SendState = value; }
		}
			
		/// <summary>
		/// SendDate发送时间
		/// </summary>		
		public virtual DateTime? SendDate
		{
			get { return _SendDate; }
			set { _SendDate = value; }
		}
			


		#endregion 	
		
		
        #region DAO操作
		
		
		/// <summary>
        /// 获取所有实体的列表
        /// </summary>
        /// <returns></returns>
        public override List<tbMobileMessageEntity> GetAll()
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("select [id],[ReceiveMobile],[SendMobile],[MessageContent],[SendState],[SendDate] from [tb_MobileMessage] ");
	
            List<tbMobileMessageEntity> list = new List<tbMobileMessageEntity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
				int seq = 0;
                while (dataReader.Read())
                {	seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		/// <summary>
        /// 获取所有实体的列表总行数
        /// </summary>
        /// <returns></returns>
        public override int GetTotalRecords()
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("  select count([id])  from [tb_MobileMessage] ");
	
            Database db = GetDatabase();
            return (int)db.ExecuteScalar(CommandType.Text, strSql.ToString());
        }
		
		/// <summary>
        /// 获取所有实体的列表总行数
        /// </summary>
        /// <returns></returns>
        public override int GetTotalRecords(string sqlCondition)
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("  select count([id])  from [tb_MobileMessage]  ");
	
			 if (sqlCondition.Trim() != "")
            {
                strSql.Append(" where " + sqlCondition);
            }
            Database db = GetDatabase();
            return (int)db.ExecuteScalar(CommandType.Text, strSql.ToString());
        }	
		
		
		/// <summary>
        /// 按条件查询,得到一页的对应的结果列表
        /// </summary>
        /// <param name="strWhere">条件</param>
		/// <param name="PageSize">每页大小</param>
		/// <param name="CurrentPageIndex">当前页码</param>
        /// <returns></returns>
		 public override List<tbMobileMessageEntity> GetAllByQuery(string strWhere, int PageSize, int CurrentPageIndex)
        {
            StringBuilder strSql = new StringBuilder();
            if (strWhere.Contains("order".ToLower()))
            {
                throw new Exception("分页查询的sql条件中不能包括排序子句，请调用重载方法实现有条件的排序筛选");
            }
		 
			strSql.Append("select top ").Append(PageSize).Append("  [id],[ReceiveMobile],[SendMobile],[MessageContent],[SendState],[SendDate] from [tb_MobileMessage] where ");

			 if (strWhere.Trim() != "")
            {
                strSql.Append("  " + strWhere + " and ");
            }
			  strSql.Append(" ID not in ( ");
			 strSql.Append(" select top ").Append(PageSize*(CurrentPageIndex-1)).Append("  [id] from [tb_MobileMessage] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere );
            }
			strSql.Append(" ) " );

            List<tbMobileMessageEntity> list = new List<tbMobileMessageEntity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
			   int seq = PageSize * (CurrentPageIndex - 1);
                while (dataReader.Read())
                {
					seq++;
                    list.Add(ReaderBind(dataReader, seq));
                }
            }
            return list;
        }
		
		
			/// <summary>
        /// 按条件查询,得到一页的对应的结果列表
        /// </summary>
        /// <param name="strWhere">条件</param>
		/// <param name="PageSize">每页大小</param>
		/// <param name="CurrentPageIndex">当前页码</param>
		/// <param name="strSort">ex:order by id desc</param>
        /// <returns></returns>
		 public override List<tbMobileMessageEntity> GetAllByQuery(string strWhere,string strSort, int PageSize, int CurrentPageIndex)
        {
            StringBuilder strSql = new StringBuilder();
            if (strWhere.Contains("order".ToLower()))
            {
                throw new Exception("分页查询的sql条件中不能包括排序子句，请调用重载方法实现有条件的排序筛选");
            }
		 
			strSql.Append("select top ").Append(PageSize).Append("  [id],[ReceiveMobile],[SendMobile],[MessageContent],[SendState],[SendDate] from [tb_MobileMessage] where ");

			 if (strWhere.Trim() != "")
            {
                strSql.Append("  " + strWhere + " and ");
            }
			  strSql.Append(" ID not in ( ");
			 strSql.Append(" select top ").Append(PageSize*(CurrentPageIndex-1)).Append("  [id] from [tb_MobileMessage] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere+" " ).Append(strSort);
            }
			strSql.Append(" ) " ).Append(strSort);

            List<tbMobileMessageEntity> list = new List<tbMobileMessageEntity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
				int seq = PageSize * (CurrentPageIndex - 1);
                while (dataReader.Read())
                {	
					seq++;
                    list.Add(ReaderBind(dataReader, seq));
                }
            }
            return list;
        }
		
		
		/// <summary>
        /// 按条件查询,得到对应的结果列表
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public override List<tbMobileMessageEntity> GetAllByQuery(string strWhere)
        {
			strWhere = SQLInjectionFilter(strWhere);
            StringBuilder strSql = new StringBuilder();
			strSql.Append("select [id],[ReceiveMobile],[SendMobile],[MessageContent],[SendState],[SendDate] from tb_MobileMessage ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List<tbMobileMessageEntity> list = new List<tbMobileMessageEntity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            { 
				int seq = 0;
                while (dataReader.Read())
                {
					seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		
		
		/// <summary>
        /// 按条件查询,得到对应的结果列表
        /// </summary>
        /// <param name="strWhere"></param>
		/// <param name="parameters">sql条件中的参数</param>
        /// <returns></returns>
        public override List<tbMobileMessageEntity> GetAllByQuery(string strWhere, List<IDataParameter> parameters)
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("select [id],[ReceiveMobile],[SendMobile],[MessageContent],[SendState],[SendDate] from [tb_MobileMessage] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List<tbMobileMessageEntity> list = new List<tbMobileMessageEntity>();
            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            foreach (IDataParameter sp in parameters)
            {
                db.AddInParameter(dbCommand, sp.ParameterName, sp.DbType, sp.Value);
            }

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
				int seq =0 ;
                while (dataReader.Read())
                {
					seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		
		

		
		
		/// <summary>
        /// 获取按条件查询以后的结果列表的前指定rowNumber行记录
        /// </summary>
        /// <param name="strWhere">不带where关键字的SQL条件语句</param>
        /// <param name="rowNumber"></param>
        /// <returns></returns>
        public override List<tbMobileMessageEntity> GetAllByQuery(string strWhere, List<IDataParameter> parameters, int rowNumber)
        {

            StringBuilder strSql = new StringBuilder();
			strSql.Append("select top ").Append(rowNumber).Append("  [id],[ReceiveMobile],[SendMobile],[MessageContent],[SendState],[SendDate] from [tb_MobileMessage] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List<tbMobileMessageEntity> list = new List<tbMobileMessageEntity>();
            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            foreach (IDataParameter sp in parameters)
            {
                db.AddInParameter(dbCommand, sp.ParameterName, sp.DbType, sp.Value);
            }

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {	
				int seq = 0;
                while (dataReader.Read())
                {
					seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		
		/// <summary>
        /// 获取按条件查询以后的结果列表的前指定rowNumber行记录
        /// </summary>
        /// <param name="strWhere">不带where关键字的SQL条件语句: AND AA=@AA</param>
        /// <param name="rowNumber"></param>
        /// <returns></returns>
        public override List<tbMobileMessageEntity> GetAllByQuery(string strWhere, int rowNumber)
        {
		    strWhere = SQLInjectionFilter(strWhere);
            StringBuilder strSql = new StringBuilder();
			
			strSql.Append("select top ").Append(rowNumber).Append("  [id],[ReceiveMobile],[SendMobile],[MessageContent],[SendState],[SendDate] from [tb_MobileMessage] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where  " + strWhere);
            }
            List<tbMobileMessageEntity> list = new List<tbMobileMessageEntity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
				int seq=0;
                while (dataReader.Read())
                {	
					seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		
		
		
		
		
		
        /// <summary>
        /// 按主键查询对应的实体
        /// </summary>
        /// <param name="id">主键ID</param>
        /// <returns></returns>
        public override tbMobileMessageEntity GetById(int id)
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("select [id],[ReceiveMobile],[SendMobile],[MessageContent],[SendState],[SendDate] from [tb_MobileMessage]  where id= @id ");
				
            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "id", DbType.Int32, id);
            tbMobileMessageEntity entity = null;
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    entity = ReaderBind(dataReader);
                }
            }
            return entity;

        }
		
		
		 /// <summary>
        /// 保存实体
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public override int Save()
        {
			
            if (this.id ==0)
            {
                this.id = GetMax("tb_MobileMessage");
            }
            StringBuilder strSql = new StringBuilder();
			strSql.Append("insert into  tb_MobileMessage (");
			strSql.Append("[id],[ReceiveMobile],[SendMobile],[MessageContent],[SendState],[SendDate] )");
			strSql.Append(" values (");
			strSql.Append("@id,@ReceiveMobile,@SendMobile,@MessageContent,@SendState,@SendDate)");

            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
			db.AddInParameter(dbCommand, "id", DbType.Int32, this.id);
			db.AddInParameter(dbCommand, "ReceiveMobile", DbType.String, this.ReceiveMobile);
			db.AddInParameter(dbCommand, "SendMobile", DbType.String, this.SendMobile);
			db.AddInParameter(dbCommand, "MessageContent", DbType.String, this.MessageContent);
			if (this.SendState == null)
			{
			db.AddInParameter(dbCommand, "SendState", DbType.Decimal, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "SendState", DbType.Decimal, this.SendState.Value);
			}
			if (this.SendDate == null)
			{
			db.AddInParameter(dbCommand, "SendDate", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "SendDate", DbType.DateTime, this.SendDate.Value);
			}

			return db.ExecuteNonQuery(dbCommand);
		  
      
        }
		

		
        /// <summary>
        /// 保存实体
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public override int Save(tbMobileMessageEntity entity)
        {
			
            if (entity.id == 0)
            {
                entity.id = GetMax("tb_MobileMessage");
            }
            StringBuilder strSql = new StringBuilder();
			strSql.Append("insert into  tb_MobileMessage (");
			strSql.Append("[id],[ReceiveMobile],[SendMobile],[MessageContent],[SendState],[SendDate] )");
			strSql.Append(" values (");
			strSql.Append("@id,@ReceiveMobile,@SendMobile,@MessageContent,@SendState,@SendDate)");

            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
			db.AddInParameter(dbCommand, "id", DbType.Int32, entity.id);
			db.AddInParameter(dbCommand, "ReceiveMobile", DbType.String, entity.ReceiveMobile);
			db.AddInParameter(dbCommand, "SendMobile", DbType.String, entity.SendMobile);
			db.AddInParameter(dbCommand, "MessageContent", DbType.String, entity.MessageContent);
			if (entity.SendState == null)
			{
			db.AddInParameter(dbCommand, "SendState", DbType.Decimal, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "SendState", DbType.Decimal, entity.SendState.Value);
			}
			if (entity.SendDate == null)
			{
			db.AddInParameter(dbCommand, "SendDate", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "SendDate", DbType.DateTime, entity.SendDate.Value);
			}

			return db.ExecuteNonQuery(dbCommand);
		  
      
        }
		
		
        /// <summary>
        /// 保存或者更新(如果传入的实体主键为空则保存,否则做更新操作)
        /// </summary>
        /// <param name="entity">传入的实体</param>
        /// <returns>影响的行数</returns>
        public override int SaveOrUpdate(tbMobileMessageEntity entity)
        {
			
            if (entity.id  == 0)
            {
                if (Save(entity)>0)
                {
                    return 1;
                }
                else
                {
                    return 0;
                }
            }
            else
            {
                return Update(entity);
            }
        }
		
		/// <summary>
        /// 保存或者更新(如果传入的实体主键为空则保存,否则做更新操作)
        /// </summary>
        /// <param name="entity">传入的实体</param>
        /// <returns>影响的行数</returns>
        public override int SaveOrUpdate()
        {
		
            if (this.id  == 0)
            {
                if (Save()>0)
                {
                    return 1;
                }
                else
                {
                    return 0;
                }
            }
            else
            {
                return Update();
            }
        }
		
		/// <summary>
        /// 是否存在对应主键ID的记录
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public override bool IsExist(int ID)
        {
            Database db = GetDatabase();
            StringBuilder strSql = new StringBuilder();
            			 strSql.Append("select count(1) from tb_MobileMessage where id=@id ");

            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "id", DbType.Int32, ID);//这里为ID是因为原有代码把主键都变成了ID.
            int cmdresult;
            object obj = db.ExecuteScalar(dbCommand);
            if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
            {
                cmdresult = 0;
            }
            else
            {
                cmdresult = int.Parse(obj.ToString());
            }
            if (cmdresult == 0)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
		
		
		/// <summary>
        /// 删除对应的实体
        /// </summary>
        /// <param name="entity"></param>
        public override int Delete(tbMobileMessageEntity entity)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete tb_MobileMessage ");
            strSql.Append(" where id=@id ");
            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "id", DbType.Int32, entity.id );
            return db.ExecuteNonQuery(dbCommand);
        }
		
		/// <summary>
        /// 删除主键ID对应的记录
        /// </summary>
        /// <param name="id"></param>
        public override int Delete(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete tb_MobileMessage ");
            strSql.Append(" where id=@id ");
            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "id", DbType.Int32, id);
            return db.ExecuteNonQuery(dbCommand);
        }
		
		
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public override int Update()
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update tb_MobileMessage set ");
			strSql.Append("[id]=@id,[ReceiveMobile]=@ReceiveMobile,[SendMobile]=@SendMobile,[MessageContent]=@MessageContent,[SendState]=@SendState,[SendDate]=@SendDate ");

            strSql.Append(" where id=@id ");
            Database db = GetDatabase();
			DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
			db.AddInParameter(dbCommand, "id", DbType.Int32, this.id );
			db.AddInParameter(dbCommand, "ReceiveMobile", DbType.String, this.ReceiveMobile);
			db.AddInParameter(dbCommand, "SendMobile", DbType.String, this.SendMobile);
			db.AddInParameter(dbCommand, "MessageContent", DbType.String, this.MessageContent);
			if (this.SendState == null)
			{
			db.AddInParameter(dbCommand, "SendState", DbType.Decimal, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "SendState", DbType.Decimal, this.SendState.Value);
			}
			if (this.SendDate == null)
			{
			db.AddInParameter(dbCommand, "SendDate", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "SendDate", DbType.DateTime, this.SendDate.Value);
			}

			
			return	db.ExecuteNonQuery(dbCommand);

		}
		



		
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public override int Update(tbMobileMessageEntity entity)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update tb_MobileMessage set ");
			strSql.Append("[id]=@id,[ReceiveMobile]=@ReceiveMobile,[SendMobile]=@SendMobile,[MessageContent]=@MessageContent,[SendState]=@SendState,[SendDate]=@SendDate ");

            strSql.Append(" where id=@id ");
            Database db = GetDatabase();
			DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
			db.AddInParameter(dbCommand, "id", DbType.Int32, entity.id );
			db.AddInParameter(dbCommand, "ReceiveMobile", DbType.String, entity.ReceiveMobile);
			db.AddInParameter(dbCommand, "SendMobile", DbType.String, entity.SendMobile);
			db.AddInParameter(dbCommand, "MessageContent", DbType.String, entity.MessageContent);
			if (entity.SendState == null)
			{
			db.AddInParameter(dbCommand, "SendState", DbType.Decimal, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "SendState", DbType.Decimal, entity.SendState.Value);
			}
			if (entity.SendDate == null)
			{
			db.AddInParameter(dbCommand, "SendDate", DbType.DateTime, System.DBNull.Value);
			}
			else
			{
			db.AddInParameter(dbCommand, "SendDate", DbType.DateTime, entity.SendDate.Value);
			}

			
			return	db.ExecuteNonQuery(dbCommand);

		}
		


		
		
		
		
		/// <summary>
        /// 对象实体绑定数据
		///生成构造为list的构造器
        /// </summary>
        private tbMobileMessageEntity ReaderBind(IDataReader dataReader,int seq)
        {
            ITOMMS.Entity.tbMobileMessageEntity entity = new ITOMMS.Entity.tbMobileMessageEntity();
			entity.SEQNO = seq;
            object obj;
			obj = dataReader["id"];
			 if (obj != null && obj != DBNull.Value)
			 {
			 entity.id = (int)obj;
			 }
			 entity.ReceiveMobile= dataReader["ReceiveMobile"].ToString();
			 entity.SendMobile= dataReader["SendMobile"].ToString();
			 entity.MessageContent= dataReader["MessageContent"].ToString();
			 obj=dataReader["SendState"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.SendState= (bool)obj;
			}
			 obj=dataReader["SendDate"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.SendDate= (DateTime)obj;
			}

            return entity;
        }
		
		
				/// <summary>
        /// 对象实体绑定数据
		///生成构造为list的构造器
        /// </summary>
        private tbMobileMessageEntity ReaderBind(IDataReader dataReader)
        {
            ITOMMS.Entity.tbMobileMessageEntity entity = new ITOMMS.Entity.tbMobileMessageEntity();
			object obj;
			obj = dataReader["id"];
			 if (obj != null && obj != DBNull.Value)
			 {
			 entity.id = (int)obj;
			 }
			 entity.ReceiveMobile= dataReader["ReceiveMobile"].ToString();
			 entity.SendMobile= dataReader["SendMobile"].ToString();
			 entity.MessageContent= dataReader["MessageContent"].ToString();
			 obj=dataReader["SendState"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.SendState= (bool)obj;
			}
			 obj=dataReader["SendDate"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.SendDate= (DateTime)obj;
			}

            return entity;
        }
		
		
		
		 #endregion
		
	}
}
